add_definitions(-DMACRO_WIN)
# add_definitions(-DCC_EXPORTS)
# set( my_std_pre "/std:" )

# set( basic_cxx17 "c++17" )
# set( str_cxx17 "${my_std_pre}${basic_cxx17}" )

# include( CheckCXXCompilerFlag )
# check_cxx_compiler_flag( "${str_cxx17}" _cpp_17_flag_supported )
# if ( _cpp_17_flag_supported )
#     set( CMAKE_CXX_STANDARD 17 )
#     message("_cpp_17_flag_supported")
# else()
# message("_cpp_17_flag_no_supported")
# endif()

project(CCEngine)


file(GLOB HEADERS_src "src/*.h")
file(GLOB HEADERS_Core "src/Core/*.h")
file(GLOB HEADERS_Events "src/Events/*.h")
file(GLOB HEADERS_Renderer "src/Renderer/*.h")
file(GLOB HEADERS_ImGui "src/ImGui/*.h")
file(GLOB HEADERS_Debug "src/Debug/*.h")
file(GLOB HEADERS_Platform "src/Platform/*.h")
file(GLOB HEADERS_Scene "src/Scene/*.h")
file(GLOB HEADERS_Platform_Windows "src/Platform/Windows/*.h")
file(GLOB HEADERS_Platform_OpenGL "src/Platform/OpenGL/*.h")


include_directories(
    include
    vendor
    vendor/Glad/include
    vendor/imgui
    vendor/spdlog/include
    # vendor/entt/include
    vendor/assimp
    vendor/bullet
    vendor/freetype2
    vendor/shaderc/include
    src
    src/Core
    src/Events
    src/Renderer
    src/ImGui
    src/Debug
    src/Scene
    src/Platform/Windows
    src/Platform/OpenGL
    )
   
SET(SOURCE
    vendor/Glad/src/glad.c
    vendor/imgui/imgui.cpp
    vendor/imgui/imgui_demo.cpp
    vendor/imgui/imgui_draw.cpp
    vendor/imgui/imgui_tables.cpp
    vendor/imgui/imgui_widgets.cpp
    src/Core/application.cpp
    src/Core/window.cpp
    src/Core/log.cpp
    src/Core/layer.cpp
    src/Core/layerStack.cpp
    src/Core/UUID.cpp
    src/Core/tinyxml2.cpp
    src/Debug/GuiHelper.cpp
    src/Renderer/buffer.cpp
    src/Renderer/framebuffer.cpp
    src/Renderer/graphicsContext.cpp
    src/Renderer/orthographicCamera.cpp
    src/Renderer/perspectiveCamera.cpp
    src/Renderer/renderCommand.cpp
    src/Renderer/renderer.cpp
    src/Renderer/renderer2D.cpp
    src/Renderer/renderer3D.cpp
    src/Renderer/rendererAPI.cpp
    src/Renderer/shader.cpp
    src/Renderer/texture.cpp
    src/Renderer/uniformBuffer.cpp
    src/Renderer/vertexArray.cpp
    src/Renderer/font.cpp
    src/ImGui/imGuiBuild.cpp
    src/ImGui/imGuiLayer.cpp
    src/Scene/Entity.cpp
    src/Scene/Scene.cpp
    src/Scene/Mesh.cpp
    src/Scene/Physics.cpp
    src/Scene/Resource_manager.cpp
    src/Platform/Windows/windowsWindow.cpp
    src/Platform/Windows/windowsUtils.cpp
    src/Platform/OpenGL/openGLBuffer.cpp
    src/Platform/OpenGL/openGLContext.cpp
    src/Platform/OpenGL/openGLFramebuffer.cpp
    src/Platform/OpenGL/openGLRendererAPI.cpp
    src/Platform/OpenGL/openGLShader.cpp
    src/Platform/OpenGL/openGLTexture2D.cpp
    src/Platform/OpenGL/openGLTextureCube.cpp
    src/Platform/OpenGL/openGLUniformBuffer.cpp
    src/Platform/OpenGL/openGLVertexArray.cpp
)

link_directories( ${PROJECT_NAME}
    PRIVATE
    lib/win
    )

message("====win======" ${PROJECT_SOURCE_DIR})

if(${MYBUILD_TYPE_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")

# add_library(${PROJECT_NAME} STATIC ${SOURCE})
add_library(${PROJECT_NAME} STATIC ${SOURCE})

target_link_libraries( ${PROJECT_NAME}
    PRIVATE    
    ${PROJECT_SOURCE_DIR}/lib/win/debug/BulletCollision_Debug.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/BulletDynamics_Debug.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/LinearMath_Debug.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/BulletInverseDynamics_Debug.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/BulletSoftBody_Debug.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/freetype.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/assimpd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/glfw3.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/shaderc.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/glslangd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/shaderc_util.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/SPIRVd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/HLSLd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/SPIRV-Tools.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/SPIRV-Tools-opt.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/MachineIndependentd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/GenericCodeGend.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/OSDependentd.lib
    ${PROJECT_SOURCE_DIR}/lib/win/debug/OGLCompilerd.lib
    # ${PROJECT_SOURCE_DIR}/lib/win/spdlog.lib
    )

install (TARGETS CCEngine
    LIBRARY DESTINATION lib)

install(FILES ${HEADERS_src} DESTINATION include/)
install(FILES ${HEADERS_Core} DESTINATION include/Core/)
install(FILES ${HEADERS_Events} DESTINATION include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION include/Platform/OpenGL/)

#local
install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/lib/win/debug/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/OpenGL/)

install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/lib/win/debug/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project02/include/Platform/OpenGL/)

install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/lib/win/debug/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project03/include/Platform/OpenGL/)

install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/lib/win/debug/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project04/include/Platform/OpenGL/)

else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")

add_definitions(-DMACRO_BUILD_TYPE_RELEASE)

add_library(${PROJECT_NAME} STATIC ${SOURCE})

target_link_libraries( ${PROJECT_NAME}
    PRIVATE    
    ${PROJECT_SOURCE_DIR}/lib/win/release/BulletCollision.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/BulletDynamics.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/LinearMath.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/BulletInverseDynamics.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/BulletSoftBody.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/freetype.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/assimp.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/glfw3.lib
    # ${PROJECT_SOURCE_DIR}/lib/win/spdlog.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/shaderc.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/glslang.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/shaderc_util.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/SPIRV.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/HLSL.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/SPIRV-Tools.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/SPIRV-Tools-opt.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/MachineIndependent.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/GenericCodeGen.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/OSDependent.lib
    ${PROJECT_SOURCE_DIR}/lib/win/release/OGLCompiler.lib
    )

install (TARGETS CCEngine
    LIBRARY DESTINATION lib)
	
install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/lib/win/release/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project01/include/Platform/OpenGL/)

install (FILES D:/chenchao/mysvnlocal/CommonTask/CCEngine/build/install/lib/CCEngine.lib 
    DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/lib/win/release/)

install(FILES ${HEADERS_src} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/)
install(FILES ${HEADERS_Core} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Core/)
install(FILES ${HEADERS_Events} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Events/)
install(FILES ${HEADERS_Renderer} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Renderer/)
install(FILES ${HEADERS_ImGui} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/ImGui/)
install(FILES ${HEADERS_Debug} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Debug/)
install(FILES ${HEADERS_Platform} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Platform/)
install(FILES ${HEADERS_Scene} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Scene/)
install(FILES ${HEADERS_Platform_Windows} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Platform/Windows/)
install(FILES ${HEADERS_Platform_OpenGL} DESTINATION D:/chenchao/mysvnlocal/CommonTask/CCEngineDemo/project05/include/Platform/OpenGL/)

endif()

